﻿@model MessageViewModel
<form class="form form-horizontal" asp-controller="Plus" asp-action="MessageSend" method="post">
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">收件人：</label>
		<div class="formControls col-xs-8 col-sm-9">
			@{
				if (Model.MessageID <= 0)
				{
					<span class="select-box inline">
						<select id="dropInceptType" class="select" onchange="SelectInceptType()" asp-for="InceptType">
							<option value="0">所有会员</option>
							<option value="1">指定会员</option>
							<option value="2">指定会员组</option>
						</select>
					</span>
					<span id="conIncept" style="display:none;">
						@await Component.InvokeAsync("SelectUser", new SelectUserViewModel { Prefix = "ctl", Value = ViewBag.Incept, IsRequired = true })
					</span>
					<span id="conInceptGroup" style="display:none;">
						<span class="select-box inline" style="min-width:200px;">
							<select asp-for="InceptGroup" data-val="true" data-val-required="不能为空" id="InceptGroup" class="select" style="padding:0px;width:100%;"></select>
						</span>
						<span style="color:red;" class="field-validation-valid" data-valmsg-for="InceptGroup" data-valmsg-replace="true"></span>
					</span>
				}
				else
				{
					<span class="select-box inline">
						<select id="dropInceptType" class="select" asp-for="InceptType">
							<option value="1">指定会员</option>
						</select>
					</span>
					<span id="conIncept">
						@await Component.InvokeAsync("SelectUser", new SelectUserViewModel { Prefix = "ctl", Value = ViewBag.Incept, IsRequired = true })
					</span>
				}
			}
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">发件人：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" asp-for="Sender">
			<span asp-validation-for="Sender" style="color:red;"></span>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">标题：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" asp-for="Title">
			<span asp-validation-for="Title" style="color:red;"></span>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">内容：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<textarea class="textarea" asp-for="Content"></textarea>
			<span asp-validation-for="Content" style="color:red;"></span>
		</div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<button class="btn btn-primary radius" type="submit">发送</button>
			<button class="btn btn-default radius" type="button" onclick="layer_close()">取消</button>
			<input type="hidden" asp-for="MessageID" />
			<span style="color:red; font-size:18px;">@Html.ValidationSummary(true)</span>
		</div>
	</div>
</form>
@section scripts{
	<script type="text/javascript">
		function SelectInceptType() {
			var InceptType = $("#dropInceptType").val();
			if (InceptType == "0") {
				$("#conIncept").hide();
				$("#conInceptGroup").hide();
			}
			else if (InceptType == "1") {
				$("#conIncept").show();
				$("#conInceptGroup").hide();
			}
			else if (InceptType == "2") {
				$("#conIncept").hide();
				$("#conInceptGroup").show();
			}
		}
		$(function () {
			var result = "@Model.result";
			if (result == "ok") {
				HuiRefresh();
			}
			else
			{
				loadUserGroupsAjax("InceptGroup", "@Model.InceptGroup", true);
				SelectInceptType();
			}
		});
	</script>
}
